package meterMonitor.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;

public class RestfulUtils extends RestfulBaseUtils{

    final static Logger logger            = LoggerFactory.getLogger(RestfulUtils.class);

    /**
     * 普通 rest请求
     */
    public static RestTemplate restTemplate      = new RestTemplate();

    /**
     * @throws Exception 
     * restHttpPost(泛型参数请求方法)
     * @param url 请求URL
     * @param object 请求参数
     * @param clazz 返回参数类型
     * @return
     * @return T
     * @exception
     */
    public static <T> T restHttpPost(String url, Object object, Class<T> clazz) {
		try {
			return restHttpPost(url,clazz,object);
		} catch (Exception e) {
			throw new BizException("200000", e);
		}
    }
    
    /**
     * restfullHttpPost(服务请求公共方法)
     * @param url 调用URL
     * @param request 请求参数
     * @return 返回参数class
     * @throws Exception
     * @return String
     * @exception
     */
    public static <T> T restfullHttpPost(String url, Object request, Class<T> clazz) {
        /* 判断服务是否以cloud形式调用 */
//        if (Constant.SERVICE_CLOUD_REQUEST) {
//            return restHttpPostCloud(url, request,clazz,restTemplateCloud);
//        }
        return restHttpPost(url,clazz, request);
    }
}